package com.dc.refactoring._3_重新组织数据._12_ReplaceTypeCodeWithSubClasses.step3;

/**
 * Description: 雇员类
 * @author: gdc
 * @date: 2020/11/30
 * @version 1.0
 */
public abstract class Employee {

    /**
     * 工程师
     */
    public static final int ENGINEER = 0;
    /**
     * 推销员
     */
    public static final int SALESMAN = 1;
    /**
     * 经理
     */
    public static final int MANAGER = 2;

    abstract int getType();

    static Employee create(int type){
        switch (type){
            case ENGINEER:
                return new Engineer();
            case SALESMAN:
                return new Salesman();
            case MANAGER:
                return new Manager();
            default:
                throw new IllegalArgumentException();
        }
    }
}
